package com.xuecheng.content.controller;

import com.xuecheng.commons.model.dto.CommentListDto;
import com.xuecheng.commons.model.vo.CommentListVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.content.service.CourseCommentService;
import com.xuecheng.teaching.api.TeachingClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/*
 * 机构的评论部分
 * */

@Slf4j
@RestController
@RequestMapping("/m/course-comment")
public class CourseCommentController {
    @Autowired
    private CourseCommentService courseCommentService;
    @Autowired
    private TeachingClient teachingClient;

    /*
     * 删除评论
     * Path： /content/m/course-comment/{commentId}
     * Method： DELETE
     * commentId 		评论ID
     * */
    @DeleteMapping("/{commentId}")
    public ResponseResult delete(@PathVariable long commentId) {
        teachingClient.delete(commentId);
        return ResponseResult.okResult();
    }

    /*
     *机构的评论列表
     *Path： /content/m/course-comment/list-all
     * Method： GET
     * Content-Type 	application/json 	是
     * */
    @GetMapping("/list-all")
    public ResponseResult commentListAll(@RequestBody CommentListDto dto) {
        ResponseResult<List<CommentListVo>> result = teachingClient.listAll(dto);
        return ResponseResult.okResult(result);
    }

}
